$('#header1-left li:first-child').hover(function() {
	$('#talk-box').css('display', 'block')

}, function() {
	$('#talk-box').css('display', 'none')

})
$('#header1-left li:nth-child(2)').hover(function() {
	$('#qq-box').css('display', 'block')

}, function() {
	$('#qq-box').css('display', 'none')

})

$('.header2-content ul li:nth-child(3)').hover(function() {
	$('#gezhong-box p:nth-child(1)').css('display', 'block')

}, function() {
	$('#gezhong-box p:nth-child(1)').css('display', 'none')

})

$('.header2-content ul li:nth-child(4)').hover(function() {
	$('#gezhong-box p:nth-child(2)').css('display', 'block')

}, function() {
	$('#gezhong-box p:nth-child(2)').css('display', 'none')

})
$('.header2-content ul li:nth-child(5)').hover(function() {
	$('#gezhong-box p:nth-child(3)').css('display', 'block')

}, function() {
	$('#gezhong-box p:nth-child(3)').css('display', 'none')

})
$('.header2-content ul li:nth-child(6)').hover(function() {
	$('#gezhong-box p:nth-child(4)').css('display', 'block')

}, function() {
	$('#gezhong-box p:nth-child(4)').css('display', 'none')

})

$('#search').click(function(e) {
	$('#search-togg').slideDown(200);
	e.stopImmediatePropagation()

})
$(document).click(function() {
	$("#search-togg").slideUp();
});

//友情链接
$('.friend-title a').hover(function() {
//	$('.title-area img').eq($(this).index() - 1).slideUp()
//	$('.title-area img').eq($(this).index() + 1).hide()
	$('.title-area img').eq($(this).index()).show(300)

},function(){
	
	$('.title-area img').eq($(this).index()-1).hide(300)
})

$('.fenqu li').hover(function() {
	$('.fenqu li').eq($(this).index()).css('opacity', '1')
}, function() {
	$('.fenqu li').eq($(this).index()).css('opacity', '0.7')

})

//轮播图

$('.pagination li').eq(0).addClass('check');

var currentIndex = 0;

var count = $('.slide li').length;
console.log(count)

function currentPlay() {
	$('.pagination li').eq(currentIndex).addClass('check');

	$('.pagination li').eq(currentIndex).siblings().removeClass('check');

	$('.slide li').eq(currentIndex).animate({
		'width': '1200px'
	}, 500).siblings().animate({
		'width': '0px'
	}, 500);
}

function nextPlay() {
	currentIndex = currentIndex >= count - 1 ? 0 : currentIndex + 1;

	currentPlay()
}

var timer = setInterval(nextPlay, 3000);

$('.pagination li').click(function() {
	clearInterval(timer);

	currentIndex = $(this).index();

	currentPlay();

	timer = setInterval(nextPlay, 3000);
})

$('#showPic').hover(function() {
	clearInterval(timer)
	$('.controls li').css('display', 'block')

}, function() {
	$('.controls li').css('display', 'none')

	currentIndex = $(this).index() + 1;
	timer = setInterval(nextPlay, 3000)
})
$('#showPic .pagination li').hover(function() {
	//鼠标悬停时候关闭定时器
	clearInterval(timer)
	//获取当前鼠标悬停在.slide li时，获取 li 对应的索引

	var pointIndex = $(this).index()
	console.log(pointIndex)

	//设置页面样式
//	$('#showPic .slide li').eq(pointIndex).css('z-index', '2')
//		.siblings().css('z-index', '1');
	$('#showPic .pagination li').eq(pointIndex).addClass('check')
		.siblings().removeClass('check')

}, function() {
	//鼠标离开时
	//修改 currentIndex的值，为当前离开的li的索引再加1.
//	currentIndex = $(this).index()
//	timer = setInterval(nextPlay(), 2500)
})

$('.controls .prev').click(function() {
	clearInterval(timer);

	currentIndex = currentIndex <= 0 ? count - 1 : currentIndex - 1;

	currentPlay();

	timer = setInterval(nextPlay, 3000);
})

$('.controls .next').click(function() {
	clearInterval(timer);

	nextPlay();

	timer = setInterval(nextPlay, 3000);
})

$(function() {
	var h = $(document).scrollTop();
	$(window).scroll(function() {
		var scrollY = $(document).scrollTop();
		if(scrollY > 290) {
			$('#fix-nav').css({
				'display': 'block',
				'position': 'fixed',
				'top': 0,
				'z-index': '100',
			})
		} else {
			$('#fix-nav').css('display', 'none')
		}

	})
})
//返回顶部hover
$('.topback').hover(function() {
	$(this).css("background-image", "url(images/top2.png)")
}, function() {
	$(this).css("background-image", "url(images/top.png)")
})

//返回顶部click
$('.topback').click(function() {
	$('body,html').animate({
		scrollTop: 0
	}, 300);
	return false;
})

//上传
var current = false;
$('.addcontent').hover(function() {
	$('.adddetail').fadeIn();
	current = true;
}, function() {

	if(current = true) {
		$('.adddetail').hover(function(event) {
			event.stopImmediatePropagation();
		}, function() {
			$('.adddetail').fadeOut();
		})
	} else {
		$('.adddetail').fadeOut();
	}

})

//阻止链接跳转
$('a').on('click', function(ev) {
	ev.preventDefault();
})